﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once

#include "GnufExtension.h"
#include <GnufINotificationCenterEventHandler.h>
#include <IUiDocumentEventHandler.h>
#include <IUiViewEventHandler.h>

namespace gcmp {
    class IUiDocument;
    class IUiView;
    class IWidget;
}

namespace gnuf {
// Deprecated! ////////////////////////////////////////////////////////////////////////////////////
    class ArrangementAreaContent;
    enum class EGnufIntergrationComponentType : std::uint8_t
    {
        eDisplayFilter,
        eModelView,
        ePickFilter,
        ePropertyPalette,
        eSideToolBar,
        eDetailDrawing
    };

    class GNUF_EXTENSION_EXPORT IGnufIntergrationComponent
    {
    public:
        virtual void onUiDocumentActivated(gcmp::IUiDocument *) = 0;
        virtual gcmp::IWidget * onGetIWidget() = 0;
        virtual gnuf::ArrangementAreaContent * onGetArrangementAreaContent() = 0;
    };
///////////////////////////////////////////////////////////////////////////////////////////////////

    class INotificationCenterEventArgs;

    class GNUF_EXTENSION_EXPORT GnufIntegration
#if 0   // Deprecated! -frank 2022-09-23
        : public gnuf::INotificationCenterEventHandler,
        , public gcmp::IUiDocumentEventHandler,
        , public gcmp::IUiViewEventHandler
#endif  // Deprecated! -frank 2022-09-23
    {
    private:
        GnufIntegration();
        ~GnufIntegration();
    public:
        static GnufIntegration * get();

        static bool isSubUiView(gcmp::IUiView *);
        static void setRenamed(gcmp::IUiView *);

// Deprecated! ////////////////////////////////////////////////////////////////////////////////////
        bool addComponent(EGnufIntergrationComponentType, IGnufIntergrationComponent *);
        IGnufIntergrationComponent * componentOf(EGnufIntergrationComponentType) const;
        bool  isVisible(EGnufIntergrationComponentType) const;
        void setVisible(EGnufIntergrationComponentType, bool);
///////////////////////////////////////////////////////////////////////////////////////////////////
        
    protected:
#if 0   // Deprecated! -frank 2022-09-23
        // Inheirs from INotificationCenterEventHandler...
        virtual void onEvent(gnuf::INotificationCenterEventArgs *) override;
        // Inheirs from gcmp::IUiDocumentEventHandler...
        virtual void On(gcmp::IUiDocumentEventArgs *) override;
        // Inheirs from gcmp::IUiViewEventHandler...
        virtual void On(gcmp::IUiViewEventArgs *) override;
#endif  // Deprecated! -frank 2022-09-23
    private:
        void setActiveUiDocument(gcmp::IUiDocument *);

        std::unordered_map<EGnufIntergrationComponentType, IGnufIntergrationComponent *> m_components;
        gcmp::WeakPtr<gcmp::IUiDocument> m_activeUiDocument;
        bool m_closingUiDocument;
        gcmp::WeakPtr<const gcmp::IUiView> m_closingUiViewByUI;
    };

}
